{% load notifications_tags cache %}
{% notifications_unread as unread_count %}
{% cache 180 notifications request.user.id unread_count %}
<li class="dropdown notifications-menu">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
    <i class="fa fa-bell-o"></i>
    {% if unread_count %}
        <span class="label label-warning">{{ unread_count }}</span>
    {% endif %}
  </a>
  <ul class="dropdown-menu">
    <li class="header">
      {%if unread_count%}
      您有 <span class="text-red">{{ unread_count }}</span> 条未读消息
      {%else%}
      您没有未读消息
      {%endif%}
    </li>
    <li>
      <!-- inner menu: contains the actual data -->
      <ul class="menu">
        {%for unread in request.user.notifications.unread%}
        <li>
          <a id="{{unread.id}}" href="{{unread.target.get_absolute_url}}">
            <i class="{{unread.target.icon}} {{unread.target.icon_color}}"></i> {{unread.verb}}
          </a>
        </li>
        {%endfor%}
      </ul>
    </li>
    {%if unread_count > 5%}
    <li class="footer"><a href="#">查看所有</a></li>
    {%endif%}
  </ul>
</li>
{% endcache %}